﻿function register() {
    jzcode.event.registerEvent('popup-close', function () {
        // 返回到原始状态
        g_isPopup = false;
        GotoMainMode();

        for (var index = 0; index < g_nodeArr[0].tools.length; index++) {
            if (g_nodeArr[0].tools[index].event != null) {
                g_nodeArr[0].tools[index].isSelected = false;
            }
        }
        for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
            if (g_node_rudder_big.tools[index].event != null) {
                g_node_rudder_big.tools[index].isSelected = false;
            }
        }
        g_node_rudder.show = true;
        g_node_rudder_big.show = false;
        g_node_rudder_c1.show = false;
        g_node_rudder_c2.show = false;
    });
    jzcode.event.registerEvent('popup-rudder', function () {
        GotoSubMode();
        for (var index = 0; index < g_nodeArr.length; index++) {
            g_nodeArr[index].isSelected = false;
        }
        g_node_rudder.show = false;
        g_node_rudder_big.show = true;
        g_node_rudder_big.isSelected = true;
    });
    jzcode.event.registerEvent('rudder-popup01', function () {
        if (g_node_rudder_c1.show) {
            g_isPopup = false;
            for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
                g_node_rudder_big.tools[index].isSelected = false;
            }
            g_node_rudder_c1.show = false;
        } else {
            GotoSubMode();
            closeChart();
            g_isPopup = true;
            for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
                if (g_node_rudder_big.tools[index].event == 'rudder-popup01') {
                    g_node_rudder_big.tools[index].isSelected = true;
                } else {
                    g_node_rudder_big.tools[index].isSelected = false;
                }
            }
            g_node_rudder_c1.show = true;
            g_node_rudder_c2.show = false;
        }
    });
    jzcode.event.registerEvent('rudder-popup02', function () {
        if (g_node_rudder_c2.show) {
            for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
                g_node_rudder_big.tools[index].isSelected = false;
            }
            g_node_rudder_c2.show = false;
        } else {
            GotoSubMode();
            closeChart();
            g_isPopup = false;
            for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
                if (g_node_rudder_big.tools[index].event == 'rudder-popup02') {
                    g_node_rudder_big.tools[index].isSelected = true;
                } else {
                    g_node_rudder_big.tools[index].isSelected = false;
                }
            }
            g_node_rudder_c1.show = false;
            g_node_rudder_c2.show = true;
        }
    });
    jzcode.event.registerEvent('chart-wtsld', function () {
        GotoSubMode();
        g_isPopup = true;

        g_node_rudder_c1.show = false;
        g_node_rudder_c2.show = false;
        showChartWTSLD();
        for (var index = 0; index < g_nodeArr[0].tools.length; index++) {
            if (g_nodeArr[0].tools[index].event == 'chart-wtsld') {
                g_nodeArr[0].tools[index].isSelected = true;
            } else {
                g_nodeArr[0].tools[index].isSelected = false;
            }
        }
    });
    jzcode.event.registerEvent('warn-wtsld', function () {
        GotoSubMode();
        g_isPopup = true;
        g_node_rudder_c1.show = false;
        g_node_rudder_c2.show = false;
        showWarnWTSLD();
        for (var index = 0; index < g_nodeArr[0].tools.length; index++) {
            if (g_nodeArr[0].tools[index].event == 'warn-wtsld') {
                g_nodeArr[0].tools[index].isSelected = true;
            } else {
                g_nodeArr[0].tools[index].isSelected = false;
            }
        }
    });
    jzcode.event.registerEvent('top-wtsld', function () {
        GotoSubMode();
        g_isPopup = true;
        g_node_rudder_c1.show = false;
        g_node_rudder_c2.show = false;
        showCustWTSLD();
        for (var index = 0; index < g_nodeArr[0].tools.length; index++) {
            if (g_nodeArr[0].tools[index].event == 'top-wtsld') {
                g_nodeArr[0].tools[index].isSelected = true;
            } else {
                g_nodeArr[0].tools[index].isSelected = false;
            }
        }
    });
    jzcode.event.registerEvent('chart-tg', function () {
        GotoSubMode();
        showChartTG();
    });
    jzcode.event.registerEvent('chart-zc', function () {
        GotoSubMode();
        showChartZC();
    });
    jzcode.event.registerEvent('chart-dg', function () {
        GotoSubMode();
        showChartDG();
    });
    jzcode.event.registerEvent('select-rudder-big', function () {
        if (g_node_rudder_big.isSelected) {
            // 返回到原始状态
            g_isPopup = false;
            GotoMainMode();

            for (var index = 0; index < g_nodeArr[0].tools.length; index++) {
                if (g_nodeArr[0].tools[index].event != null) {
                    g_nodeArr[0].tools[index].isSelected = false;
                }
            }
            for (var index = 0; index < g_node_rudder_big.tools.length; index++) {
                if (g_node_rudder_big.tools[index].event != null) {
                    g_node_rudder_big.tools[index].isSelected = false;
                }
            }
            g_node_rudder.show = true;
            g_node_rudder_big.show = false;
            g_node_rudder_c1.show = false;
            g_node_rudder_c2.show = false;
        } else {
            jzcode.com.foreach(g_nodeArr, function (item, args) {
                if (item.event != 'select-rudder-big')
                    item.isSelected = false;
                else
                    item.isSelected = true;
            });
        }
    });
    jzcode.event.registerEvent('select-wtsld', function () {
        jzcode.com.foreach(g_nodeArr, function (item, args) {
            if (item.event != 'select-wtsld')
                item.isSelected = false;
            else
                item.isSelected = true;
        });
    });
    jzcode.event.registerEvent('select-tg', function () {
        jzcode.com.foreach(g_nodeArr, function (item, args) {
            if (item.event != 'select-tg')
                item.isSelected = false;
            else
                item.isSelected = true;
        });
    });
    jzcode.event.registerEvent('select-zc', function () {
        jzcode.com.foreach(g_nodeArr, function (item, args) {
            if (item.event != 'select-zc')
                item.isSelected = false;
            else
                item.isSelected = true;
        });
    });
    jzcode.event.registerEvent('select-dg', function () {
        jzcode.com.foreach(g_nodeArr, function (item, args) {
            if (item.event != 'select-dg')
                item.isSelected = false;
            else
                item.isSelected = true;
        });
    });
};